package mt.filter;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import mt.Order;
import mt.dummy.ServerCommDummy;


public class AnalyticsFilterTest {

	private ServerCommDummy decoretserver;
	private AnalyticsFilter analyticFilter;
	private Order order;
	private int buyOrder = 0;
	private int sellOrder = 0;

	@Before
	public void setup(){
		analyticFilter = new AnalyticsFilter(decoretserver);
	}

	@Test
	public void testGetNextMessage() {

		//2.
		String nick1="Trading...";
		String nick2="Selling...";
		String nick3="Buying...";
		String nick4="Buying1...";
		String nick5="Selling1...";


		analyticFilter.sendOrder(nick1, order);
		analyticFilter.sendOrder(nick2, order);
		analyticFilter.sendOrder(nick3, order);

		assertFalse(analyticFilter.clientIsConnected(nick1));
		assertFalse(analyticFilter.clientIsConnected(nick1));
		assertFalse(analyticFilter.clientIsConnected(nick1));

		//3.
		analyticFilter.sendOrder(nick3, order);
		analyticFilter.sendOrder(nick4, order);
		analyticFilter.sendOrder(nick5, order);

		assertEquals(buyOrder/analyticFilter.getTotalBuyOrders(), analyticFilter.getTotalBuyOrders());
		assertEquals(sellOrder/analyticFilter.getTotalBuyOrders(), analyticFilter.getTotalSellOrders());


		//4. 
		for (int i = 0; i < analyticFilter.getNicksBanned().size(); i++) {
			if(analyticFilter.getNicksBanned().get(nick1).equals(nick1))
				analyticFilter.disconnectClient(nick1);
		}
		assertFalse(analyticFilter.clientIsConnected(nick1));



	}

}






